home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / tex / ntex / get_ntex < prev    next >
Text File  |  1996-11-16  |  21KB  |  605 lines

  1. #!/bin/bash
  2. # (is this the correct PATH of `bash'?,
  3. #  try also: `#!/usr/bin/bash')
  4. #
  5. # The DOCUMENTATION can be found at the end of the script 
  6. #
  7. # Copyright Volker B"orchers 1996
  8. # email: boercher@physik.uni-bremen.de
  9. #
  10. SCRIPTNAME="get_ntex"
  11.  
  12. ## enable function caching:
  13. set -h
  14. ## enable debugging:
  15. ##set -x
  16.  
  17. ##>>>>>>>>>>>>>>> Default settings: >>>>>>>>>>>>>>>>
  18.  
  19. ## darfnix (please use one of the mirrors close to you!):
  20. #SITE="darfnix.mathematik.uni-stuttgart.de"
  21. #NTEXDIR="/pub/tex/ntex/ntex"
  22. ## sunsite (look for mirrors):
  23. #SITE="sunsite.unc.edu"
  24. #NTEXDIR="/pub/Linux/apps/tex/ntex"
  25. ## official TeX sites:
  26. #NTEXDIR="/tex-archive/systems/unix/linux/ntex"
  27. #SITE="ftp.dante.de" # (Germany)
  28. #SITE="ftp.shsu.edu" # (USA)
  29. #SITE="ftp.tex.ac.uk" # (UK)
  30.  
  31. LOCDIR="$PWD" # (You MUST use a absolute path!)
  32. DIRS="base extras fixes fonts japanese languages sources systems ntex"
  33. ##    nb-  nx-    * *   nf-   nj-      nl-       ns-     NTeX-bi * *
  34. ##   (translation into filename prefixes)
  35.  
  36. ## Special actions. Valid values are:
  37. ## `all': get whole distribution (option `-a')
  38. ## `update': get latest update (option `-u')
  39. ## `index': get index/description files (option `?')
  40. SPECIAL=""
  41.  
  42. ## The alias for all the Files in the NTeX `root' directory:
  43. ROOT="BUGS CHANGES INDEX INSTALL NTeX.announce NTeX.lsm README.NTeX RELEASE"
  44.  
  45. ## The list of files to get if the option was `?' (at least `INDEX'!):
  46. QUEST="CHANGES INDEX NTeX.lsm README.NTeX RELEASE"
  47.  
  48. ## The NTeX version that you have now (needed for the `-u' option,
  49. ## i.g. updating means to get all files that changed since CURR_VERSION):
  50. CURR_VERSION=2.0.2
  51.  
  52. ## For the `-u' option: Files that will be updated with every
  53. ## new release
  54. EVERYUPDATE="$ROOT ntex"
  55.  
  56. ## Temporary files:
  57. TMPFILE="/tmp/get_ntex.tmp.$$"
  58. TMPlst="/tmp/get_ntex.lst.$$"
  59. TMPftp="/tmp/get_ntex.ftp.$$"
  60. trap "rm -f $TMPFILE $TMPlst $TMPftp" 0 1 2 15
  61. rm -f $TMPFILE $TMPlst $TMPftp # (for security reasons!)
  62. echo -n > $TMPlst
  63.  
  64. ##<<<<<<<<<<<<<<<< Default settings <<<<<<<<<<<<<<<<<<<<
  65.  
  66. BEGINTIME="`date`"
  67.  
  68. ######## add_to_listfile ################################
  69. ## has one argument: a file containing files/packages or
  70. ## directories to get. From the file all comments (`#')
  71. ## are stripped and every name (originally separated by
  72. ## whitespace or `,') will be put into one line. (We have
  73. ## to force `awk' to recalculate the lines.)
  74. ## The result will be appended to TMPlst.
  75. function add_to_listfile () {
  76.   sed "s,#.*,," $1 \
  77.    | awk '{ OFS="\n"; FS=","; $(NF+1) = ""; print }' \
  78.    | awk '{ OFS="\n"; $(NF+1) = ""; print }'>> "$TMPlst"
  79. }
  80. ##########################################################
  81. ############# Get options and variables: #################
  82. if [ -z "$1" ]; then
  83.   ERROR=1
  84. else
  85.   LSTFILE="" #(accept no default for this)
  86.   while [ -n "$1" ]; do
  87.     case $1 in
  88.       ?)   SPECIAL="$SPECIAL index"; shift;;
  89.       -f*) LSTFILE="${1#-?}"; shift
  90.        [ -z $LSTFILE ] && { LSTFILE=$1; shift }
  91.          add_to_listfile "$LSTFILE";;
  92.       -s*) SITE="${1#-?}"; shift
  93.        [ -z $SITE ] && { SITE=$1; shift };;
  94.       -n*) NTEXDIR="${1#-?}"; shift
  95.        [ -z $NTEXDIR ] && { NTEXDIR=$1; shift };;
  96.       -l*) LOCDIR="${1#-?}"; shift
  97.        [ -z $LOCDIR ] && { LOCDIR=$1; shift }
  98.          if [ "${LOCDIR#/}" = "$LOCDIR" ]; then
  99.            echo -e "\a(STOP) Local Directory $LOCDIR must be\
  100.         \nspecified with an absolute path! No actions performed."
  101.            exit 1
  102.          fi;;
  103.       -a)  SPECIAL="$SPECIAL all"; shift;;
  104.       -u)  SPECIAL="$SPECIAL update";
  105.        SET_CURR_VERSION="${1#-?}"; shift
  106.        [ -z "$SET_CURR_VERSION" ] && { SET_CURR_VERSION=$1; shift }
  107.        [ -n "$SET_CURR_VERSION" ] && CURR_VERSION=$SET_CURR_VERSION;;
  108.       *)   echo "$*" > "$TMPFILE"
  109.          add_to_listfile "$TMPFILE"
  110.          break;;
  111.     esac
  112.   done
  113.   ## (Note: There is no consistency check)
  114. fi
  115. ## remove eventually trailing `/' from directories:
  116. LOCDIR="${LOCDIR%/}"
  117. NTEXDIR="${NTEXDIR%/}"
  118. ######################################################
  119. ################### FUNCTIONS: #######################
  120. # (We had to set the variables before)
  121.  
  122. ######## create_dir ###################################
  123. ## Creates a directory (relative or absolute path)
  124. ## This works: `create_dir /tmp/tmp1/tmp2' (with neither
  125. ## `/tmp/tmp1' nor `tmp/tmp1/tmp2' already existing) 
  126. function create_dir () {
  127.   while ! [ -d $1 ]; do
  128.     dir="$1"
  129.     while ! [ -d "$dir" ]; do
  130.       [ -z "$dir" ] && break
  131.       mkdir "$dir" 2>/dev/null || dir="${dir%/*}"
  132.     done
  133.   done
  134.   [ -d $1 ] && return 0
  135.   return 1
  136. }
  137.  
  138. ######## rtn_dir ########################################
  139. ## Returns the name of the directory where the file is
  140. ## expected to be in, e.g. `rtn_dir nb-cm' returns `base'
  141. function rtn_dir () {
  142.   case $1 in
  143.     nb-*) echo "base"; return 0;;
  144.     nx-*) echo "extras"; return 0;;
  145.     nf-*) echo "fonts"; return 0;;
  146.     nj-*) echo "japanese"; return 0;;
  147.     nl-*) echo "languages"; return 0;;
  148.     ns-*) echo "sources"; return 0;;
  149.     NTeX-bin*) echo "systems"; return 0;;
  150.     *) return 1;;
  151.   esac
  152. }
  153.  
  154. ######## get_index ######################################
  155. ## gets not only the file INDEX from SITE but all files
  156. ## specified by $QUEST:
  157. function get_index () {
  158.   cd $LOCDIR
  159.   echo "> Connecting to $SITE ..."
  160.   ftp $SITE << EOF
  161.   cd $NTEXDIR
  162.   prompt
  163.   mget $QUEST
  164.   bye
  165. EOF
  166.   if [ -s INDEX ]; then
  167.     echo "> Look for the files"
  168.     echo -e "> $tab $QUEST"
  169.     echo "> in directory $LOCDIR"
  170.   else
  171.     echo -e "\a>>>> (ERROR) Unable to get the INDEX file.\
  172.      \n>>>> Check site, local and remote directory settings!"
  173.   fi
  174. }
  175.  
  176. ######## get_all ########################################
  177. ## gets the whole distribution as one big `.tar' file
  178. ## (Only) at `darfnix.mathematik...' the directory `ntex'
  179. ## is a symbolic link to a directory with the name
  180. ## `ntex-RELEASE-No.' e.g. `ntex-2.0.2'. The `tar' at
  181. ## darfnix will only tar the link (and this is not what we want!).
  182. ## At all other sites there is only the directory `ntex' and
  183. ## we don't have to worry about the release
  184. function get_all () {
  185.   cd $LOCDIR
  186.   if [ "${SITE#darfnix}" != "$SITE" ]; then
  187.     # We have to know the release number (if not specified
  188.     # on the command line):
  189.     if [ -z "$Release" ]; then
  190.       echo "> Connecting to $SITE (get RELEASE) ..."
  191.       ftp $SITE << EOF
  192.       cd $NTEXDIR
  193.       get RELEASE
  194.       bye
  195. EOF
  196.       if ! [ -s RELEASE ]; then
  197.     echo -e "\a>>>> (ERROR) Unable to get the REALESE file.\
  198.      \n>>>> Check site, local and remote directory settings!"
  199.         return 1
  200.       fi
  201.       Release="-`grep release RELEASE | sed 's/.*=//'`"
  202.     fi
  203.   else
  204.     Release=""
  205.   fi
  206.   # Now really get the distribution:
  207.   echo "> Connecting to $SITE ..."
  208.   ftp $SITE << EOF
  209.   cd $NTEXDIR
  210.   cd ..
  211.   bin
  212.   get ntex$Release.tar
  213.   bye
  214. EOF
  215.   if [ -s ntex$Release.tar ]; then
  216.     echo "> The NTeX distribution is the \`tar' file"
  217.     echo -e "> $tab $LOCDIR/ntex$Release.tar"
  218.     echo "> Unpack it with \"tar -xvf ntex$Release.tar\""
  219.     echo "> (This creates the directory ntex$Release)"
  220.   else
  221.     echo -e "\a>>>> (ERROR) Unable to get the whole distribution.\
  222.      \n>>>> Check site, local and remote directory settings!"
  223.   fi
  224. }
  225.  
  226. ######## get_update_list ################################
  227. ## tries to get the file CHANGES from SITE and evaluate it
  228. ## according to the CURR_VERSION setting to extract the names
  229. ## of the files that changed since CURR_VERSION.
  230. ## (The idea for the method comes from Frank Langbein):
  231. function get_update_list () {
  232.   cd $LOCDIR
  233.   echo "> Connecting to $SITE to get CHANGES ..." 1>&2
  234.   ftp $SITE 1>&2 << EOF
  235.   cd $NTEXDIR
  236.   get CHANGES
  237.   bye
  238. EOF
  239.   if [ -s CHANGES ]; then
  240.     ## determine if CURR_VERSION < ACT_VERSION:
  241.     ACT_VERSION=$(egrep '^NTeX V[1-9]' CHANGES \
  242.      | cut -dV -f2 \
  243.      | cut -d, -f1 \
  244.      | tr -d '.' \
  245.      | awk -v current=`echo $CURR_VERSION | tr -d '.'` \
  246.            '{if ($1 > current) {
  247.                print substr($1,1,1) "." substr($1,2,1) "." substr($1,3,1)
  248.                exit
  249.            }}')
  250.     if [ -n "$ACT_VERSION" ]; then
  251.       update_file=$LOCDIR/update-`date +"%d.%b.%y"`
  252.       echo -n > $update_file
  253.       egrep '^N(.-|TeX V[1-9])' CHANGES | cut -d, -f1 \
  254.        | sed -e "s,NTeX V,#release," -e "s, V.*\$,," -e 's,^.*Changes$,,' \
  255.        | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' \
  256.        | awk -v current=$CURR_VERSION 'BEGIN { doprint=1 } {
  257.              if(doprint==1) {
  258.            print $1; if($0 ~ current) {doprint=0}
  259.          }}' \
  260.        > $TMPFILE
  261.       ## ("tr 'A-Z' 'a-z'" did not work on some machines)
  262.       echo "#Things that change with every release:" >> $TMPFILE      
  263.       echo "$EVERYUPDATE" >> $TMPFILE
  264.       grep -v "\*" $TMPFILE > $update_file
  265.       ## to cope with wildcards in changes (e.g. ns-*) -
  266.       ## we then have to get the whole directory
  267.       WILDCARDS="`grep '\*' $TMPFILE`"
  268.       for this in $WILDCARDS; do
  269.     rtn_dir $this >> $update_file
  270.       done
  271.       echo -e \
  272.        "> Updating from current version $CURR_VERSION to release $ACT_VERSION.\
  273.        \n> The names of the updated packages can be found in $UPDATE_LIST" 1>&2
  274.       echo "$update_file"
  275.     else
  276.       echo -e "\a>>>> You already have the latest NTeX version ($CURR_VERSION)\
  277.        \n>>>> - Nothing to do." 1>&2
  278.       ## is the following line OK (is /dev/null really empty?) ???
  279.       echo "/dev/null"
  280.     fi
  281.     return 0
  282.   else
  283.     echo -e "\a>>>> (ERROR) Unable to get the file CHANGES.\
  284.      \n>>>> Check site, local and remote directory settings"
  285.     ## is the following line OK (is /dev/null really empty?) ???
  286.     echo "/dev/null"
  287.     return 1
  288.   fi
  289. }
  290.  
  291. ######################################################
  292. ################### STARTUP: #########################
  293. tab="\40"
  294. USE="\a* USAGE:\
  295.  \n*\t $SCRIPTNAME [options] [packages]\
  296.  \n*+ Options:\
  297.  \n* $tab \`?'\t\t\tGet some files that helps you to decide which \
  298.  \n*\t\t\t$tab packages you want. (INDEX, CHANGES, ...) \
  299.  \n* $tab \`-f file'\t\t\`file' should contain a list of packages (e.g.\
  300.  \n*\t\t\t$tab \`nb-ltx2e') and/or directories (base, extras, ..)\
  301.  \n* $tab \`-s Site'\t\tThe NTeX site\
  302.  \n* $tab \`-n NTeX dir'\tThe full path of the NTeX directory at the site\
  303.  \n* $tab \`-l local dir'\tThe directory to place NTeX (the \"root\"\
  304.  \n*\t\t\t$tab directory where the subdirs \`base', \`extra' are in)\
  305.  \n* $tab \`-u' [current_version] $tab Get all packages that changed\
  306.  \n* \t\t\t$tab since \`current_version'. The default for the\
  307.  \n* \t\t\t$tab optional \`current_version' is \`$CURR_VERSION'.\
  308.  \n* $tab \`-a' [release]\tGet the whole NTeX distribution as one big \`.tar'\
  309.  \n* \t\t\t$tab file. (WARNING: >35MB!) The optional \`release'\
  310.  \n* \t\t\t$tab (e.g. \`2.0.2') only makes sense on SITE \`darfnix'.\
  311.  \n* \t\t\t$tab If it's not specified get latest official release.\
  312.  \n*+ Defaults:\
  313.  \n* $tab Site=\"$SITE\"\
  314.  \n* $tab NTeX dir=\"$NTEXDIR\"\
  315.  \n* $tab local dir=\"$LOCDIR\"\
  316.  \n* $tab Special actions=\"$SPECIAL\"\
  317.  \n* $tab Current version=\"$CURR_VERSION\""
  318.  
  319. EXAMPLE="*+ How to specify the files/packages you want? \
  320.  \n* $tab (The syntax for the command line and for the \
  321.  \n* $tab \`file' (with \`-f' option) is the same!) \
  322.  \n- - - - - - - - - A sample file: - - - - - - - - - \
  323.  \n# Everything after a \`#' will be ignored. \
  324.  \n# First we want the complete directory \`ntex': \
  325.  \nntex/ \t# (it contains the basic installation files) \n\
  326.  \n# Then all basic packages (as a directory) \
  327.  \nbase \t# (the trailing \`/' is optional) \n\
  328.  \n# Some other packages (extras, a font and 2 language specific): \
  329.  \nextras/nx-feynm.pkg,nx-bibl nx-music, nf-bbold \
  330.  \nlanguages/nl-russ.pkg, nl-thai \
  331.  \n# Note that you can mix different ways to specify them: \
  332.  \n# + Files may be separated by whitespace and/or commas. \
  333.  \n# + For packages with a basename \`n?-'... (e.g. nl-russ, nx-bibl), \
  334.  \n# $tab you can do without the path and the suffix \`.pkg'! \n\
  335.  \n# Now we want the binaries for Linux and for AIX machines - \
  336.  \n# the path and suffix \`release.tar.gz' is also NOT required: \
  337.  \nsystems/NTeX-bin-i486-linux-2.1.0.tar.gz NTeX-bin-AIX\n\
  338.  \n# At last we want all regular files in the NTeX-\`root' directory \
  339.  \n# (CHANGES, INDEX, INSTALL, README.NTeX, ...). For this there is \
  340.  \n# a special KEYWORD: \
  341.  \nroot \
  342.  \n----------------- End of the example file ----------"
  343.  
  344. VERSION="* $0, version 1.0, 04/23/1996"
  345. echo "$VERSION"
  346. ## only a little check:
  347. if [ -z "$SITE" -o -z "$NTEXDIR" -o -z "$LOCDIR" ]; then
  348.   echo -e "\a> Missing Argument or missing default setting:\
  349.    \n> Site=\"$SITE\", Lokal dir.=\"$LOCDIR\", NTeX dir.=\"$NTEXDIR\"\
  350.    \n\n$USE"
  351.   exit 1
  352. fi
  353. ## print help message, if script is called without arguments:
  354. [ "$ERROR" = 1 ] \
  355.  && { echo -e "$USE\n\n$EXAMPLE"; exit 1 }
  356.  
  357. ## create the local directories (if they don't exist).
  358. ## The directory structure is the same as in SITE:
  359. [ -d $LOCDIR ] || create_dir $LOCDIR
  360. if ! cd $LOCDIR; then
  361.   echo -e "\a(STOP) Local Directory $LOCDIR doesn't exist!\
  362.    \nNo actions performed."
  363.   exit 1
  364. else
  365.   mkdir $DIRS >&/dev/null
  366.   cd $OLDPWD
  367. fi
  368.  
  369. { grep "$SITE" $HOME/.netrc > /dev/null \
  370.  || grep "default" $HOME/.netrc > /dev/null }\
  371.  || { echo -e "\a(STOP) ~/.netrc not configured.\
  372.  \nAdd one of the following two lines to it:\
  373.  \n $tab machine $SITE login anonymous password YOUR_EMAIL_ADDRESS\
  374.  \nor: $tab default login anonymous password YOUR_EMAIL_ADDRESS\
  375.  \nand shut it for all others by \"chmod 600 ~/.netrc\""; exit 1 }
  376.  
  377. ##########################################################
  378. ################## MAIN: #################################
  379. for this in $SPECIAL; do
  380.   case $this in
  381.     index) get_index ;;
  382.     all) get_all ;;
  383.     update) UPDATE_LIST=`get_update_list`
  384.         add_to_listfile $UPDATE_LIST;;
  385.     *) echo -e "\a(STOP) No such SPECIAL \`$this'"; exit1;;
  386.   esac
  387. done
  388.  
  389. ## Now every information about files to get (from the command
  390. ## line, from the `-f' or `-u' option) is contained in TMPlst.
  391.  
  392. ## files don't have to be specified with an absolute path
  393. if grep "^/" $TMPlst >&/dev/null; then
  394.   echo -e "\a>>>> (ERROR) The following files will be ignored:"
  395.   grep "^/" $TMPlst
  396.   echo "<<< (Don't use absolute pathnames)"
  397. fi
  398.  
  399. ############# some monster pipes: ###################
  400. ####### 1) the packages:
  401. ## all requested packages should be specified the same way:
  402. ## `nb-ltx2e' - without path and `.pkg' suffix
  403. ## (every filename starting with `n', followed by an arbitrary
  404. ## letter followed by `-' is assumed to be a package!)
  405. packs="`grep "^n.-" $TMPlst \
  406.  | sed 's,.*/,,g' \
  407.  | sed 's,\..*,,g' \
  408.  | sort | uniq`" 2>/dev/null
  409. ####### 2) the binary packages:
  410. bins="`grep 'NTeX-bin-' $TMPlst \
  411.  | sed 's,.*/,,g' \
  412.  | sed 's,.tar.gz,,'`"
  413. ####### all other:
  414. grep -v '^n.-' $TMPlst \
  415.  | egrep -v '(^/)|(NTeX-bin-)' \
  416.  | sed "s,/\$,," \
  417.  | sort | uniq >$TMPFILE  2>/dev/null
  418. ####### 3) the directories `base', `extras', ...:
  419. ## (force awk to recalculate a line)
  420. dir_reg_expr="/^(`echo $DIRS | awk '{OFS=")|("; 
  421.               $(NF+1)=""; NF=NF-1; print}'`)$/"
  422. dirs=`grep -v "/" $TMPFILE | awk "$dir_reg_expr"`
  423. ####### 4) other files:
  424. ## duplicate the lines containing DIRS and BINS:
  425. for this in $dirs; do echo -e $this >> $TMPFILE; done
  426. ## remove lines that appear more than once
  427. other=`sort $TMPFILE | uniq -u`
  428.  
  429. ########### create a ftp batchfile: #################
  430. ## clean the ftp batchfile:
  431. echo -n > $TMPftp
  432. echo "bin" >> $TMPftp
  433.  
  434. ## complete subdirectories of NTEXDIR
  435. ## (we assume, that the server understands the meaning
  436. ## of appending the `.tar' suffix to the directory name)
  437. if [ -n "$dirs" ]; then
  438.   echo "cd $NTEXDIR" >> $TMPftp
  439.   echo "lcd $LOCDIR" >> $TMPftp
  440.   for this in $dirs; do
  441.     echo "get $this.tar" >> $TMPftp
  442.     ## unpacking should be done after the script has ended
  443.     ## not this: echo "! tar -xf $this.tar &" >> $TMPftp
  444.     ## but this:
  445.     echo "> Get directory $this as a \`.tar' file. Unpack it"
  446.     echo "> with tar -xvf $this.tar"
  447.   done
  448. fi
  449.  
  450. ## binary packages:
  451. if [ -n "$bins" ]; then
  452.   echo "cd $NTEXDIR/systems" >> $TMPftp
  453.   echo "lcd $LOCDIR/systems" >> $TMPftp
  454.   # mget allowes to do without release and `tar.gz' suffix.
  455.   # (This also allowes to easyly specify ALL binarys with
  456.   # `NTeX-bin-'!)
  457.   echo "prompt" >> $TMPftp
  458.   for this in $bins; do
  459.     echo "mget $this*" >> $TMPftp
  460.   done
  461.   echo "prompt" >> $TMPftp
  462. fi
  463.  
  464. ## packages:
  465. last_dir=""
  466. if [ -n "$packs" ]; then
  467.   for this in $packs; do
  468.     this_dir=`rtn_dir $this` \
  469.      || { echo -e "\a>>>> (INTERNAL ERROR) \`$this' is\
  470.      no package."; continue }
  471.     if [ "$this_dir" != "$last_dir" ]; then
  472.       echo "cd $NTEXDIR/$this_dir" >> $TMPftp
  473.       echo "lcd $LOCDIR/$this_dir" >> $TMPftp
  474.       last_dir=$this_dir
  475.     fi
  476.     echo "get $this.pkg" >> $TMPftp
  477.   done
  478. fi
  479.  
  480. ## other:
  481. if [ -n "$other" ]; then
  482.   echo "cd $NTEXDIR" >> $TMPftp
  483.   echo "lcd $LOCDIR" >> $TMPftp
  484.   last_dir=""
  485.   for this in $other; do
  486.     ## get all the (regular) files in NTEXDIR ?:
  487.     if [ $this = "root" ]; then
  488.       echo "cd $NTEXDIR" >> $TMPftp
  489.       echo "prompt" >> $TMPftp
  490.       echo "mget $ROOT" >> $TMPftp
  491.       echo "prompt" >> $TMPftp
  492.       continue
  493.     fi
  494.     this_file="${this##*/}"
  495.     this_dir="${this%/*}"
  496.     [ "$this_file" = "$this_dir" ] && this_dir=""
  497.     if [ "$this_dir" != "$last_dir" ]; then
  498.       echo "cd $NTEXDIR/$this_dir" >> $TMPftp
  499.       echo "lcd $LOCDIR/$this_dir" >> $TMPftp
  500.       last_dir=$this_dir
  501.     fi
  502.     echo "get $this_file" >> $TMPftp
  503.   done
  504. fi
  505.  
  506. ######### get the files using the batchfile: #########
  507. if grep "get " $TMPftp >&/dev/null; then
  508.   echo "bye" >> $TMPftp
  509.   echo "> Connecting to $SITE ..."
  510.   ftp $SITE < $TMPftp
  511.   cp $TMPftp $LOCDIR
  512.   echo "> Ready! - A list of all actions performed on the site"
  513.   echo "> $SITE can be found in the file"
  514.   echo -e "> $tab $LOCDIR/get_ntex.ftp"
  515. fi
  516. echo "> \`$SCRIPTNAME' started at $BEGINTIME"
  517. echo -ne "> \tand ended at\t"; date
  518.  
  519. ## Cleanup
  520. rm -f $TMPFILE $TMPlst $TMPftp
  521.  
  522. exit 0  ## <---END---OF---THE---SCRIPT
  523.  
  524. ================== DOCUMENTATION: ==============================
  525. This script provides an easy way to get NTeX- files or packages via
  526. `ftp'. It is especially designed to be working at night when all your
  527. compeditors are sleeping (see section `at night'). It has default
  528. settings for the site to get NTeX from and for the directory where
  529. NTeX is. (An example for the way to specify the files you want is
  530. printed if you call the script without an argument.)
  531.  
  532. `get_ntex' first creates (on default in the current working
  533. directory) all the directories that are contained in the
  534. NTeX root directory at the site:
  535. "base extras fixes fonts japanese languages sources systems ntex"
  536. The script then gets the packages and files you specified and puts
  537. them in the right subdirectories.
  538.  
  539. One note on getting the whole distribution (option `-a') and
  540. complete subdirectories (e.g. `base'): You will only have one file
  541. (e.g. `base.tar') instead of the files in the directories first.
  542. You will have to unpack them with `tar -xf ...' (the skript will tell
  543. you about that).
  544.  
  545. ------------------- INSTALLATION: -----------------------------
  546. 1) If you want, try it immediately e.g. with
  547.       ` get_ntex '
  548.    If it worked, `get_ntex' only gives you information on how to
  549.    use it (since you called the script without arguments).
  550.    Now call `get_ntex' with an argument! For example say:
  551.       ` get_ntex nb-amstx '
  552.    If it really gets the `AmsTeX' package and puts it into the
  553.    `base' subdirectory of your local directory (./) everything
  554.    should be alright.
  555. 2) If there was the error `No such file or directory', the path
  556.    of bash is not correctly set. Try
  557.       ` bash get_ntex nb-amstx '
  558.    If this worked you may want to set the correct path of `bash'
  559.    in the first line of this script. First find out
  560.    the absolute path of `bash':
  561.    
  562.    in `csh':                 `which bash'
  563.    in `sh' or `bash':        `type bash'
  564.    (LINUX-default is `/bin/bash', on UNIX often also
  565.    `/usr/local/bin/bash')
  566.    Then edit the first line of the script for the path of `bash'
  567. 3) For the automatic ftp login procedure you will need a file
  568.     `~/.netrc' with an entry for the site of your choice.
  569.     (Alternatively a `default' entry - but not all ftp daemons
  570.     support it). `get_ntex' will figure it out for itself if your
  571.     `~/.netrc' file exists and is OK or not, and will tell you what
  572.     to do, if not.
  573. 4) If you want edit the section between `>>> Default Settings: >>>'
  574.    and `<<< Default Settings: <<<'. The meaning of the variables are
  575.    explained there. (Especially think about the best SITE to get
  576.    NTeX from.)
  577. 5) Install `get_ntex' somewhere where the shell can
  578.    find it if you like it, else delete it!
  579.  
  580. ------------------ at night: ----------------------------------
  581. If you want to let your computer do the job at a given hour
  582. (e.g. 23:55) you should say some hours before (when you are awake):
  583. `at 23:55 << EOF
  584. /PATH_OF_GET_NTEX/get_ntex -l `INSTALL_DIECTORY' -f `files_I_want'
  585. EOF'
  586.  
  587. -> For every file use an absolute path!
  588. -> Don't forget to specifiy the lokal directory!
  589.  
  590. ---------------------- BUGS: ----------------------------------
  591. * The script should be able to deal with wildcards
  592. * The script has grown too big and is not as easy to understand as
  593. I like it.
  594.  
  595. ---------------------- ACKNOWLEDGEMENT: -----------------------
  596. I have to thank Frank Langbein, the maintainer of NTeX, for his
  597. engagement, for suggestions and help (especially with the `-u' option)
  598.   
  599. ---------------------
  600. If you find `get_ntex' useful, have suggestions, improvements,
  601. ... write to:
  602.  
  603.  boercher@physik.uni-bremen.de
  604.  
  605.